package com.jy.api.service.impl;

import com.jy.api.dao.MemberDao;
import com.jy.api.domain.WechatSendTemplate;
import com.jy.api.service.MemberV1Service;
import com.jy.api.service.WechatTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lihu on 2018/1/15.
 */
@Service
public class MemberV1ServiceImpl implements MemberV1Service {

    @Autowired
    MemberDao memberDao;

    @Autowired
    WechatTemplateService wechatTemplateService;


    @Async
    @Override
    public void sendActivityWechat(String storeId, WechatSendTemplate wechatSendTemplate) {
        List<Object> openIds = memberDao.getStoreAllOpenIds(storeId);
        for (Object o : openIds) {
            wechatTemplateService.sendActivity(wechatSendTemplate, o.toString());
        }

    }

}
